<template>
<div>
   <div class="box">
  <el-page-header  title="编辑通知" @click="cancle()">
 
</el-page-header>

    </div>
  <div class="app">
 
    <div class="boxone">
      <p>学生id：</p>
      <input type="text"  v-model="text1">
 
    </div>
       <div class="boxone">
      <p>老师id：</p>
      <input type="text" v-model="text2">
 
    </div>
   
    <div class="boxthree">
        <p>用药日期:</p>
  <div class="block">

      <el-date-picker
        v-model="value1"
        type="datetime"
        placeholder="Select date and time"
      />
    </div>
   
    </div>
    <div class="four">
        <p>内容标题：</p>
         <el-input
    v-model="textarea1"
    autosize
    type="textarea"
     input-style='width:500px'
    placeholder="请输入内容"
  />
    </div> 
    <div class="four">
        <p>内容详情：</p>
         <el-input
    v-model="textarea2"
    autosize
    type="textarea"
     input-style='width:500px'
    placeholder="请输入内容"
  />
    </div>   
    <div class="five">
   <el-button type="primary" @click="add()">发送</el-button>
    </div>
  </div>
  </div>
</template>

<script setup>
import server from "@/api/index.ts";
import { ref } from 'vue'
import { useRouter } from 'vue-router'
//文本框
const textarea1 = ref('')
const textarea2 = ref('')
// 日期
const value1 = ref('')
const text1 = ref('')
const text2 = ref('')
//获取路由管理实例
var router = useRouter();
var cancle=()=>{
router.push('/index/jiaxiaohudong/jiankang');
}
var add=async()=>{
var times=timeConversion(value1.value)
console.log(times);
var res =await server.jiaxiaohutong.addlink({title:textarea2.value,sId:text1.value,tId:text2.value,time:times, detail:textarea1.value})
console.log(res);
 if (res.data.code == 200) {
     ElNotification.success({ message: '查看成功' })
     router.push('/index/jiaxiaohudong/jiankang');
  }

}
// 时间转换
function timeConversion(time) {
  const timeE = new Date(time)
  const year = timeE.getFullYear();
  const month = timeE.getMonth() + 1; // 返回值范围是0~11，需要加1才是实际月份
  const day = timeE.getDate();
  const hour = timeE.getHours()+'0';
  const minute = timeE.getMinutes()+'0';
  const second = timeE.getSeconds()+'0';

  const ti = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  return ti
}
  // 日期
  import { h, shallowRef } from 'vue'
var tim=timeConversion(value1.value)
const customPrefix = shallowRef({
  render() {
    return h('p', 'pre')
 
  },
})

</script>

<style scoped>
.box{
  height: 50px;
  margin: 0 30px;
  margin-top: 50px;
  border-bottom: 1px solid #000;

}
.app{
    padding-left: 100px;
        padding-top:50px;
        padding-bottom:50px;
          background-color: #fff;
}
.boxone{
    display: flex;
 margin: 10px 0;

    margin-left: 30px;
   
}
.boxtwo{
    display: flex;
    height: 50px;
 /* margin-bottom: 15px; */
    margin-left: 100px;
}
.boxthree{
     display: flex;
    margin-left: 8px;
}
.boxthree p{
    margin-right: 15px;
    line-height: 30px;
}
.four{
    display: flex;
     margin-left: 10px;
       margin-top: 30px;
}
.five{
      margin-left: 110px;
       margin-top: 20px;
}

</style>